#include<iostream>
using namespace std;
int arr[100010];
int s[100010];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int ans = 0;
	for (int i = 0 , j = 0; i < n; i++) {
		s[arr[i]]++;
		while (s[arr[i]] > 1) {
			s[arr[j]]--;
			j++;
		}
		ans = max(ans, i - j + 1);
	}
	cout << ans << endl;
	return 0;
}